package com.tuantuan.common.exception;

import com.tuantuan.common.base.result.Responses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;


/**
 * 全局Error/404处理
 *
 * @author wangqinmin
 * @date 2018/08/05
 */
@ApiIgnore
@Configuration
@RestController
public class GlobalErrorController implements ErrorController {

    private static final Logger logger = LoggerFactory.getLogger(GlobalErrorController.class);

    private static final String ERROR_PATH = "/error";

    @RequestMapping(ERROR_PATH)
    public Responses handleError() {
        logger.error("404 NOT FOUND");
        //return new Responses(CommonConstant.NOT_FOUND, "您未登陆 或 你请求的路径不存在");
        return null;
    }

    /**
     * 请求服务器为404时,返回提示
     *
     * @return
     */
    @Override
    public String getErrorPath() {
        logger.error("errorPath....");
        return ERROR_PATH;
    }
}
